package com.huanying.goodjob.job;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.huanying.framework.user.User;
import com.huanying.goodjob.jobtype.Jobtype;
import com.huanying.goodjob.message.Message;
import com.huanying.goodjob.skill.Skill;

@Entity
@Table(name = "jobitem")
public class Jobitem implements Serializable {
	
	private static final long serialVersionUID = -1754597476546916167L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	
	@ManyToOne(cascade = CascadeType.ALL, optional = true, fetch = FetchType.LAZY)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "job_id")
	private Job job; // 所属工作
	
	@OneToOne(cascade = CascadeType.ALL)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "jobtype_id")
	private Jobtype jobtype;   //工种
	
	private double area;  //面积
	private int unit;  //面积单位
	private double salary; // 薪水
	private Date pre_start_date; //预计开工时间
	private Date start_date;  // 开始时间
	private Date end_date;  // 结束时间
	private Date end_request_date;  //请求完工时间
	private double urgent_fee;  //加急费用
	
	@Column(name = "urgent_status", nullable = false, columnDefinition = "INT default 0")
	private int urgent_status; // 加急状态
	
	@Column(name = "jobitem_status", nullable = false, columnDefinition = "INT default 0")
	private int jobitem_status; // 工作项状态
	//5.请求开工   4.请求完工   3.被选中   2.有人接单，等待选中 1.施工中 0.未有人接单 -1.等待评价 -2.结束
	
	@Column(name = "status", nullable = false, columnDefinition = "INT default 1")
	private int status; // 状态
	
	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "jobitem", fetch = FetchType.EAGER)
	private transient List<Jobitem_User> jobitem_users;
	
	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "jobitem", fetch = FetchType.EAGER)
	private transient List<Rework> reworks;
	
	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "jobitem", fetch = FetchType.EAGER)
	private transient List<Jobitemstatus_Change> jobitemstatus_changes;
	
	@OneToMany(cascade = CascadeType.REFRESH, mappedBy = "jobitem", fetch = FetchType.EAGER)
	@Transient
	private List<Message> messages;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Job getJob() {
		return job;
	}

	public void setJob(Job job) {
		this.job = job;
	}

	public Jobtype getJobtype() {
		return jobtype;
	}

	public void setJobtype(Jobtype jobtype) {
		this.jobtype = jobtype;
	}

	public double getArea() {
		return area;
	}

	public void setArea(double area) {
		this.area = area;
	}

	public int getUnit() {
		return unit;
	}

	public void setUnit(int unit) {
		this.unit = unit;
	}

	public Date getEnd_date() {
		return end_date;
	}

	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}

	public Date getPre_start_date() {
		return pre_start_date;
	}

	public void setPre_start_date(Date pre_start_date) {
		this.pre_start_date = pre_start_date;
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	public Date getStart_date() {
		return start_date;
	}

	public double getUrgent_fee() {
		return urgent_fee;
	}

	public void setUrgent_fee(double urgent_fee) {
		this.urgent_fee = urgent_fee;
	}

	public int getUrgent_status() {
		return urgent_status;
	}

	public void setUrgent_status(int urgent_status) {
		this.urgent_status = urgent_status;
	}

	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}

	public Date getEnd_request_date() {
		return end_request_date;
	}

	public void setEnd_request_date(Date end_request_date) {
		this.end_request_date = end_request_date;
	}

	public int getJobitem_status() {
		return jobitem_status;
	}

	public void setJobitem_status(int jobitem_status) {
		this.jobitem_status = jobitem_status;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public List<Message> getMessages() {
		return messages;
	}

	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}

	public List<Jobitemstatus_Change> getJobitemstatus_changes() {
		return jobitemstatus_changes;
	}

	public void setJobitemstatus_changes(List<Jobitemstatus_Change> jobitemstatus_changes) {
		this.jobitemstatus_changes = jobitemstatus_changes;
	}

	public List<Rework> getReworks() {
		return reworks;
	}

	public void setReworks(List<Rework> reworks) {
		this.reworks = reworks;
	}

	public List<Jobitem_User> getJobitem_users() {
		return jobitem_users;
	}

	public void setJobitem_users(List<Jobitem_User> jobitem_users) {
		this.jobitem_users = jobitem_users;
	}

}
